package com.sixth.controller;

import com.sixth.entity.Role;
import com.sixth.service.RoleService;
import com.sixth.util.CommonResult;
import com.sixth.util.TableLayUi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: project01
 * @description:
 * @author: 高振杨
 * @create: 2021-12-17 19:32
 **/
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @RequestMapping("/findAll")  //查询全部
    public TableLayUi list(int page, int limit){
        return  roleService.findRoleByPage(page,limit);
    }


    //员工信息中下拉框查询
    @RequestMapping("/SelectAll")
    public CommonResult findAll(){
        CommonResult all = roleService.SelectAll();
        return  all;
    }

    //修改或者增加
    @RequestMapping("/addOrUpdate")
    public CommonResult addOrUpdate(Role role){ return  roleService.addOrUpdate(role);}

    //通过id删除
    @RequestMapping("/delById")
    public CommonResult delById(Integer roleid) { return roleService.delById(roleid); }

    @RequestMapping("/getOneRole")
    public CommonResult getOneRole(String rolename){
        CommonResult oneRole = roleService.getOneRole(rolename);
        return  oneRole;
    }
}
